package com.ynet.middleground.riskmanage.model;

import java.util.List;

import org.dozer.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ynet.core.common.BaseReqObj;
import com.ynet.middleground.riskmanage.dao.ServiceMapper;
import com.ynet.middleground.riskmanage.dto.ServiceDTO;
import com.ynet.middleground.riskmanage.entity.Service;
import com.ynet.middleground.riskmanage.utils.BeanUtil;

/**
 * @author liulx
 * @description 服务列表处理
 * @date 2020-08-12 10:11
 */
@Component
public class ServicesModel {

    @Autowired
    private Mapper mapper;

    @Autowired
    private ServiceMapper serviceMapper;

    /**
     * 查询对接企查查的服务列表
     * 
     * @param req 基础请求对象
     * @return 企查查接口列表
     */
    public List<ServiceDTO> listServicesForQicahca(BaseReqObj req) {
        LambdaQueryWrapper<Service> queryWrapper = new LambdaQueryWrapper<>();
        // 企查查 ServiceProvider 编码为：0005
        queryWrapper.eq(Service::getServiceProvider, "0005");
        List<Service> serviceList = serviceMapper.selectList(queryWrapper);
        return BeanUtil.mapList(mapper, serviceList, ServiceDTO.class);
    }

}
